package day01;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayDemo {
    /*
    将一个意长度的int数组拆分为两个int数组，一个数组中存储奇数数据，一个数组中存储偶数数据，拆分后保持原有顺序。给定数组:
{1,6,2,3,9,10,7,23,22} 结果为: [1,3,9,7,23} 和{6,2,10,22}
     */
    public static void main(String[] args) {

        Integer.valueOf(127);

        int[] arr = {1,6,2,3,9,10,7,23,22};
        List<Integer> a1 = new ArrayList<>();
        List<Integer> a2 = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0){
                a1.add(arr[i]);
            }else{
                a2.add(arr[i] );
            }
        }
        System.out.println("原数组："+Arrays.toString(arr));
        System.out.println("偶数组："+Arrays.toString(a1.toArray()));
        System.out.println("奇数组："+Arrays.toString(a2.toArray()));
    }
}
